﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Manage/MasterPage.master" AutoEventWireup="true" CodeFile="UploadMaterials.aspx.cs" Inherits="Manage_UploadMaterials" %>
<%@ Register Src="~/Manage/CmsMessageBox.ascx" TagName="MessageBox" TagPrefix="cms" %>
<%@ Register Assembly="CKEditor.NET" Namespace="CKEditor.NET" TagPrefix="CKEditor" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
    <script type="text/javascript">
        $(document).ready(function () {
            $('#Comment').width($('#Body table.Info').width());
            
             $('#<%=SelectAnnex.ClientID %>').click(function () {
                var v = showModalDialog('./UploadFile.aspx?type=annex', null, 'dialogWidth:300px;dialogHeight:150px;center:yes;help:yes;resizable:yes;status:no');
                if (v != null) {
                    var vs = v.split('|');

                    $('#<%=SelectAnnex.ClientID %>').before('<span id="' + vs[0] + '" class="Annex">' + vs[1] + '</span>');
                }

                seriesAnnex();

                //设置双击事件
                $('span.Annex').dblclick(function () {
                    deleteAnnex($(this));
                });

                return false;
            });

            $('span.Annex').dblclick(function () {
                deleteAnnex($(this));
            });

            function seriesAnnex() {
                var ids = [];
                $('span.Annex').each(function () {
                    ids[ids.length] = $(this).attr('id');
                });

                $('#<%=AnnexID.ClientID %>').val(ids.join('|'));
            }

            function deleteAnnex(annex) {
                if (Cms_Confirm('确认删除选中的附件吗？')) {
                    $(annex).remove();

                    seriesAnnex();
                }
            }
        });
    </script></asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="body" Runat="Server">
    <cms:MessageBox ID="MessageBox" runat="server" />
    <asp:HiddenField ID="ArticleID" runat="server" />
    <asp:HiddenField ID="TrainID" runat="server" />
    <asp:HiddenField ID="ArticleTitle" runat="server" />
    <table class="Info" cellspacing="1">
        <tr>
            <td align="right" style="width: 100px">链接资料：</td>
            <td>
                <CKEditor:CKEditorControl ID="ArticleBody" runat="server" Height="400px" Skin="v2"></CKEditor:CKEditorControl>
            </td>
        </tr>
        <tr>
            <td align="right">附件资料：</td>
            <td>
                <%
                    if (annexes != null)
                    {
                        foreach (Annex a in annexes)
                        {
                %>
                        <span id="<%=a.ID %>" class="Annex"><%=a.Title%></span>    
                <%
                        }
                    }
                %>

                <asp:Button ID="SelectAnnex" runat="server" Text="添加资料" /><asp:HiddenField ID="AnnexID" runat="server" />
            </td>
        </tr>
        <tr>
            <td colspan="2" align="center"><asp:Button ID="Save" runat="server" Text="保存" 
                    onclick="Save_Click"/><asp:Button ID="VerifyArticle" runat="server" Text="通过审核" 
                    onclick="VerifyArticle_Click" Visible="False" /></td>
        </tr>
    </table>
    <div id="Comment">
        <p>注：</p>
        <p>1、上传图片时，请保证图片高度宽度比为4:3，文件大小不超过1MB。</p>
    </div>
</asp:Content>

